<!DOCTYPE html>

<meta charset="utf-8" />	

<form class="form-horizontal" role="form"  onsubmit="return submitForm(this);"
 action="mpamng/term/eidtTermFee.do" id="termFee_form">
 	<input type="hidden" id="type" name="type" />
 	<input type="hidden" id="feeCode" name="feeCode" />
 	<input type="hidden" id="terminalId" name="terminalId" />
 	<input type="hidden" id="agentId" name="agentId" />
 	
	<!-- #section:elements.form -->
	<br/>
	<div class="form-group">
		<label class="col-sm-2 control-label no-pEditing-right"for="form-field-1"> 合作商名称 </label>
		<div class="col-sm-8">
			<input type="text" id="agentName" name="agentName" placeholder="合作商编号" class="col-xs-10 col-sm-7" readonly="readonly"/>
		</div>
	</div>

	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 终端物理号 </label>
		<div class="col-sm-8">
			<input type="text" id="terminalNo" name="terminalNo" placeholder="终端物理号" class="col-xs-10 col-sm-5" readonly="readonly"/>
		</div>
	</div>
	
	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right">
			民生类(%)： </label>
		<div class="col-sm-3">
			<input type="text" id="rateLivelihood" name="rateLivelihood" placeholder="民生类(0.38%)"
				class="col-xs-12 col-sm-12 feecheck" value="" judge="agentRate"/>
		</div>
	</div>
	
	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right">
			一般类(%)： </label>
		<div class="col-sm-3">
			<input type="text" id="rateGeneral" name="rateGeneral" placeholder="一般类(0.78%)" 
				class="col-xs-12 col-sm-12 feecheck" value="" judge="agentRate"/>
		</div>
	</div>
	
	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right">
			餐娱类(%)： </label>
		<div class="col-sm-3">
			<input type="text" id="rateEntertain" name="rateEntertain" placeholder="餐娱类(1.25%)"
				class="col-xs-12 col-sm-12 feecheck" value="" datatype="money" judge="agentRate"/>
		</div>
	</div>
	
	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right">
			批发类(%)： </label>
		<div class="col-sm-3">
			<input type="text" id="rateGeneralTop" name="rateGeneralTop" placeholder="批发类(0.78%)"
				class="col-xs-12 col-sm-12 feecheck" value="" judge="agentRate"/>
		</div>
		<label class="col-sm-2 control-label no-padding-right">
			批发类封顶(元)： </label>
		<div class="col-sm-3">
			<input type="text" id="rateGeneralMaximun" name="rateGeneralMaximun" placeholder="批发类封顶(0.78%，单位元)" 
				class="col-xs-12 col-sm-12 feecheck" value="" datatype="money" judge="agentRate" judge-ref="rateGeneralTop"/>
		</div>
	</div>
	
	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right">
			房产类(%)： </label>
		<div class="col-sm-3">
			<input type="text" id="rateEntertainTop" name="rateEntertainTop" placeholder="房产类封顶(1.25%)" 
				class="col-xs-12 col-sm-12 feecheck" value="" datatype="money" judge="agentRate"/>
		</div>
		<label class="col-sm-2 control-label no-padding-right">
			房产类封顶(元)： </label>
		<div class="col-sm-3">
			<input type="text" id="rateEntertainMaximun" name="rateEntertainMaximun" placeholder="房产类封顶(1.25%，单位元)" 
				class="col-xs-12 col-sm-12 feecheck" value="" datatype="money" judge="agentRate" judge-ref="rateGeneralTop"/>
		</div>
	</div>
	<br/><br/>
	<div class="form-actions align-right  form-button-box" style="margin-top: 10px">
		<button id="save" class="btn btn-info" type="submit">保存</button>
		&nbsp; 
		<button class="btn" type="button" onclick="javascript:dialog.closeById('dlg-termFeeEdit');">关闭</button>
	</div>
	
</form>
<script type="text/javascript">

$(document).ready(function() {
	setType();
}); 

var agentInf;
function setType(){
	var dialog=$("#dlg-termFeeEdit").Dialog();
	if(dialog.pageParam.type=='view'){
		$("#save").remove();
		$("#termFee_form input[type=text]").attr("readonly","readonly");
		$("#termFee_form input[type=text]").attr("placeholder","");
	}else{
		// 异步加载合作商费率参数
		msg_Title="终端";
		$.ajax({
			type : "post",
			url : "mpamng/agent/outOfRate.do",
			data:{rateType:"term",agentId:dialog.pageParam.agentId},
			dataType : 'json',
			success : function(result) {
				if (result.rspcod != 200) {
					msg.alert("错误", result.rspmsg + " 错误代码："+ result.rspcod, 'error');
				} else {
					agentInf=result.obj;
				}
			},
			error : function(XMLHttpRequest, textStatus) {
				msg.alert("错误", "错误代码：" + XMLHttpRequest.status + ",错误描述："+ textStatus, 'error');
			}
		});
	}
}

function submitForm(obj){
	var $form = $('#termFee_form');
	var bool = TDValidateForm($form);
	if(!bool){
		return false;
	}
// 	留作备份
// 	$("#rateGeneralMaximun").val(parseFloat($("#rateGeneralMaximun").val())*100);
// 	$("#rateEntertainMaximun").val(parseFloat($("#rateEntertainMaximun").val())*100);
	return validateCallback(obj,editUserDone);
}

function editUserDone(result){
	if(result.rspcod== 200){
		msg.alert("提示",result.rspmsg,'correct');
		$("#grid-table").trigger("reloadGrid");
		dialog.closeById('dlg-termFeeEdit');
	}else{
		msg.alert("错误",result.rspmsg+" 错误代码："+result.rspcod,'error');
	}
}
</script>
